package com.example.repository;

import com.example.POJO.Blog;
import com.example.POJO.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface UserRepository extends JpaRepository<User, Long> {

  User findUserByUsername(String username);

/*
        CREATE TABLE `m_user` (

          `id` bigint(20) NOT NULL AUTO_INCREMENT,
          `username` varchar(64) DEFAULT NULL,
          `avatar` varchar(255) DEFAULT NULL,
          `email` varchar(64) DEFAULT NULL,
          `password` varchar(64) DEFAULT NULL,
          `status` int(5) NOT NULL,
          `created` datetime DEFAULT NULL,
          `last_login` datetime DEFAULT NULL,

*/

  @Modifying
  @Transactional
  @Query(value = "  insert into m_user(username,password)  values(:username , :password)     " , nativeQuery = true)
  int add_user(String username, String password);

//  Page<Blog> findAll(Pageable pageable);
//  Page<Blog> findByTitleContaining(String title, Pageable pageable);
//  List<Blog> findByTitleContaining(String title, Sort sort);
}
